﻿CREATE TABLE [dbo].[Attributes] (
    [EntityID]               INT             NOT NULL,
    [AttributeID]            INT             NOT NULL,
    [AttributeValueString]   NVARCHAR (MAX)  NULL,
    [AttributeValueNumber]   NUMERIC (18)    NULL,
    [AttributeValueBit]      BIT             NULL,
    [AttributeValueBinary]   VARBINARY (MAX) NULL,
    [AttributeValueDateTime] DATETIME        NULL,
    [Approved]               BIT             NULL,
    CONSTRAINT [PK_Attributes] PRIMARY KEY CLUSTERED ([EntityID] ASC, [AttributeID] ASC),
    CONSTRAINT [FK_Attributes_DefinedAttributes] FOREIGN KEY ([AttributeID]) REFERENCES [dbo].[DefinedAttributes] ([AttributeID]),
    CONSTRAINT [FK_Attributes_Entity] FOREIGN KEY ([EntityID]) REFERENCES [dbo].[Entities] ([EntityID])
);



